//
//  GreatGodView.m
//  MoXiProject
//
//  Created by 沈晨宇 on 2017/7/17.
//  Copyright © 2017年 周筱雯. All rights reserved.
//

#import "GreatGodView.h"

@implementation GreatGodView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = baseWhiteColor;
        [self initUI];
    }
    return self;
}

-(void)initUI{
    
    UIView* line=[UIView new];
    line.backgroundColor=DEF_COLOR_MAINCOLOR;
    [self addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(4);
        make.height.mas_equalTo(18);
        make.top.equalTo(self).with.offset(5);
        make.leading.equalTo(self).with.offset(10);
    }];
    
    UILabel* faxed=[UILabel new];
    faxed.text=@"暴热大神";
    faxed.font=DEF_MyFont(15);
    faxed.textColor=baseLightBlackColor;
    faxed.textAlignment=NSTextAlignmentLeft;
    [self addSubview:faxed];
    [faxed mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(18);
        make.centerY.equalTo(line);
        make.leading.equalTo(line.mas_trailing).with.offset(5);
    }];
    
    UIView* line2=[UIView new];
    line2.backgroundColor=DEF_COLOR_F0F0F0;
    [self addSubview:line2];
    [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(DEF_DEVICE_WIDTH);
        make.height.mas_equalTo(1);
        make.top.equalTo(faxed.mas_bottom).with.offset(5);
        make.leading.equalTo(self).with.offset(0);
    }];
    
    UIView* line3=[UIView new];
    line3.backgroundColor=DEF_COLOR_F0F0F0;
    [self addSubview:line3];
    [line3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(1);
        make.height.mas_equalTo(100);//暂定
        make.top.equalTo(line2.mas_bottom).with.offset(0);
        make.leading.equalTo(self).with.offset(DEF_DEVICE_WIDTH/2-1);
    }];
    
    UIView* line4=[UIView new];
    line4.backgroundColor=DEF_COLOR_F0F0F0;
    [self addSubview:line4];
    [line4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(DEF_DEVICE_WIDTH/2-1);
        make.height.mas_equalTo(1);
        make.top.equalTo(line2.mas_bottom).with.offset(50);
        make.leading.equalTo(self).with.offset(DEF_DEVICE_WIDTH/2-1);
    }];
    
  
    UIButton* shiLiBut=[UIButton new];
    [shiLiBut addTarget:self action:@selector(shiLiButClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:shiLiBut];
    [shiLiBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(DEF_DEVICE_WIDTH/2-1);
        make.height.mas_equalTo(100);
        make.top.equalTo(line2.mas_bottom).with.offset(0);
        make.leading.equalTo(self).with.offset(0);
    }];
    
    UILabel* shiLi=[UILabel new];
    shiLi.text=@"大神实力榜";
    shiLi.textColor=base_COLOR_FFA54F;
    shiLi.font=DEF_MyFont(15);
    [self addSubview:shiLi];
    [shiLi mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(15);
        make.top.equalTo(line2.mas_bottom).with.offset(25+5);
        make.leading.equalTo(self).with.offset(10);
    }];
    
    UILabel* shiLiFax=[UILabel new];
    shiLiFax.text=@"大神汇集地！";
    shiLiFax.textColor=baseLightBlackColor;
    shiLiFax.font=DEF_MyFont(12);
    shiLiFax.numberOfLines=0;
    [self addSubview:shiLiFax];
    [shiLiFax mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(12);
        make.top.equalTo(shiLi.mas_bottom).with.offset(10);
        make.leading.equalTo(self).with.offset(10);
    }];
    
    UIImageView* shiLiImage=[UIImageView new];
    shiLiImage.image=[UIImage imageNamed:@"shili"];
    [self addSubview:shiLiImage];
    [shiLiImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(50);
        make.top.equalTo(line2.mas_bottom).with.offset(20+5);
        make.trailing.equalTo(line3.mas_leading).with.offset(-10);
    }];
    
    

    UIButton* jiangBeiBut=[UIButton new];
    [jiangBeiBut addTarget:self action:@selector(jiangBeiButClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:jiangBeiBut];
    [jiangBeiBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(DEF_DEVICE_WIDTH/2-1);
        make.height.mas_equalTo(50);
        make.top.equalTo(line2.mas_bottom).with.offset(0);
        make.leading.equalTo(line3.mas_trailing).with.offset(0);
    }];
    
    UIImageView* jiangBeiImage=[UIImageView new];
    jiangBeiImage.image=[UIImage imageNamed:@"jiangbei"];
    [self addSubview:jiangBeiImage];
    [jiangBeiImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(25);
        make.height.mas_equalTo(25);
        make.top.equalTo(line2.mas_bottom).with.offset(12);
        make.leading.equalTo(line3.mas_trailing).with.offset(10);
    }];
    
    UILabel* jiangBei=[UILabel new];
    jiangBei.text=@"大神奖励榜";
    jiangBei.textAlignment=NSTextAlignmentCenter;
    jiangBei.textColor=base_COLOR_00bbee;
    jiangBei.font=DEF_MyFont(15);
    [self addSubview:jiangBei];
    [jiangBei mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(15);
        make.centerY.equalTo(jiangBeiImage);
        make.leading.equalTo(jiangBeiImage.mas_trailing).with.offset(10);
    }];
    

    UIButton* lianHongBut=[UIButton new];
    [lianHongBut addTarget:self action:@selector(lianHongButtClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:lianHongBut];
    [lianHongBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(DEF_DEVICE_WIDTH/2-1);
        make.height.mas_equalTo(50);
        make.top.equalTo(line4.mas_bottom).with.offset(0);
        make.leading.equalTo(line3.mas_trailing).with.offset(0);
    }];
    
    UIImageView* lianHongImage=[UIImageView new];
    lianHongImage.image=[UIImage imageNamed:@"lianhong"];
    [self addSubview:lianHongImage];
    [lianHongImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(25);
        make.height.mas_equalTo(25);
        make.top.equalTo(line4.mas_bottom).with.offset(12);
        make.leading.equalTo(line3.mas_trailing).with.offset(10);
    }];
    
    UILabel* lianHong=[UILabel new];
    lianHong.text=@"大神连红榜";
    lianHong.textAlignment=NSTextAlignmentCenter;
    lianHong.textColor=DEF_COLOR_MAINCOLOR;
    lianHong.font=DEF_MyFont(15);
    [self addSubview:lianHong];
    [lianHong mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(15);
        make.centerY.equalTo(lianHongImage);
        make.leading.equalTo(lianHongImage.mas_trailing).with.offset(10);
    }];
    
    
}

- (void)shiLiButClick{
    
    if ([self.delegate respondsToSelector:@selector(shiLiButClick)]) {
        [self.delegate shiLiButClick];
    }
}

- (void)jiangBeiButClick{
    
    if ([self.delegate respondsToSelector:@selector(jiangBeiButClick)]) {
        [self.delegate jiangBeiButClick];
    }
}

- (void)lianHongButtClick{
    
    if ([self.delegate respondsToSelector:@selector(lianHongButtClick)]) {
        [self.delegate lianHongButtClick];
    }
}
@end
